package com.jeeplus.modules.guide.utils;

import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.guide.web.MobileIndexController;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JsonObjectUtils {
    private static final Logger log = LoggerFactory.getLogger(JsonObjectUtils.class);
    public static JSONObject getJson(String result){
        if(StringUtils.isBlank(result))return null;
        try {
            return JSONObject.fromObject(result);
        }catch (Exception e){
            log.error(e.getMessage());
            return null;
        }
    }

    public static String getJsonValue(String result,String key){
        if(StringUtils.isBlank(result))return null;
        try {
            return JSONObject.fromObject(result).getString(key);
        }catch (Exception e){
            log.error(e.getMessage());
            return null;
        }
    }

    public static JSONArray getJsonArray(String result){
        if(StringUtils.isBlank(result))return null;
        try {
            return JSONArray.fromObject(result);
        }catch (Exception e){
            log.error(e.getMessage());
            return null;
        }
    }
}
